package com.probox.common.entity.mapper.customer;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.probox.common.entity.domain.customer.CustomerInfo;
import com.probox.common.entity.vo.WeCom.WeComConsumptionVo;
import com.probox.common.entity.vo.WeCom.WeComCustomerVo;
import com.probox.common.entity.vo.customer.CustomerInfoLevelVo;
import com.probox.customer.api.domain.CustomerInfoVo;
import org.apache.ibatis.annotations.Param;

import java.util.Date;
import java.util.List;
import java.util.Map;

/**
 * 客户信息Mapper接口
 *
 * @author zsy
 * @date 2021-05-25
 */
public interface CustomerInfoMapper extends BaseMapper<CustomerInfo> {

    /**
     * 用户行为查询:进入小程序多少次
     * @param accountId
     * @param startTime
     * @param endTime
     * @return
     */
    public Integer getOpenTimesByUid(@Param("accountId") Long accountId,@Param("startTime") String startTime,
                                     @Param("endTime") String endTime);


    /**
     * 用户行为查询:查询客户停留页面数据
     * @param accountId
     * @param startTime
     * @param endTime
     * @return
     */
    public List<Map> selectPageVisit(@Param("accountId") Long accountId, @Param("startTime") String startTime,
                                 @Param("endTime") String endTime);



    /**
     * 用户行为查询:查询商品行为数据
     * @param accountId
     * @param startTime
     * @param endTime
     * @return
     */
    public List<Map> listProductAction(@Param("accountId") Long accountId,@Param("customerId") Long customerId, @Param("startTime") String startTime,
                                     @Param("endTime") String endTime);

    public List<CustomerInfoVo> selectCustomerInfo(List list);

    public List<CustomerInfoLevelVo> selectCustomerLevel(CustomerInfo customerInfo);

    public List<com.probox.common.entity.vo.customer.CustomerInfoVo> selectCustomerFundInfo(Long[] customerUids);

    List<CustomerInfoLevelVo> queryListSelf(com.probox.common.entity.vo.customer.CustomerInfoVo customerInfo);

    /**
     * 查询客户最近一次的消费时间
     * @param customerId
     * @return
     */
    String selectLatelyConsumptionByCustomerId(@Param("customerId") Long customerId);

    /**
     *  查询客户最近一年的消费次数
     * @param customerId
     * @param startTime
     * @param endTime
     * @return
     */
    int selectLatelyFrequencyByCustomerId(@Param("customerId") Long customerId,@Param("startTime") Date startTime,
                                              @Param("endTime") Date endTime);

    /**
     *  查询客户最近一年的消费金额
     * @param customerId
     * @param startTime
     * @param endTime
     * @return
     */
    Long selectLatelyMonetaryByCustomerId(@Param("customerId") Long customerId,@Param("startTime") Date startTime,
                                          @Param("endTime") Date endTime);



    /**
     * 企业微信客户列表
     *
     * @param customerInfo
     * @return
     */
    List<WeComCustomerVo> listCustomerByStoreId(CustomerInfo customerInfo);

    /**
     * 查询用户消费记录
     *
     * @param customerId
     * @param storeId
     * @return
     */
    List<WeComConsumptionVo> listCustomerConsumptionByCustomerId(@Param("customerId") Long customerId, @Param("storeId") Long storeId);
}
